import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: { title: 'home', icon: 'el-icon-house' }
    }]
  },
  {
    path: '/setting',
    component: Layout,
    meta: { title: '设置管理', icon: 'el-icon-setting' },
    children: [{
      path: 'admininfo',
      name: 'admininfo',
      component: () => import('@/views/setting/admin'),
      meta: { title: '管理员设置' }
    }, {
      path: 'active',
      name: 'active',
      component: () => import('@/views/setting/active'),
      meta: { title: '活动设置', icon: '' }
    },
    {
      path: 'jifen',
      name: 'jifen',
      component: () => import('@/views/setting/jifen'),
      meta: { title: '积分设置', icon: '' }
    },
    {
      path: 'probability',
      name: 'probability',
      component: () => import('@/views/setting/probability'),
      meta: { title: '预约设置', icon: '' }
    },
    {
      path: 'notification',
      name: 'notification',
      component: () => import('@/views/setting/notification'),
      meta: { title: '系统通知', icon: '' }
    },
    {
      path: 'qrpay',
      name: 'qrpay',
      component: () => import('@/views/setting/qrpay'),
      meta: { title: '支付设置', icon: '' }
    },{
      path: 'drawal',
      name: 'drawal',
      component: () => import('@/views/setting/drawal'),
      meta: { title: '提现设置', icon: '' }
    }]
  },
  {
    path: '/account',
    component: Layout,
    meta: { title: '用户管理', icon: 'el-icon-user' },
    children: [{
      path: 'account',
      name: 'account',
      component: () => import('@/views/account/index'),
      meta: { title: '用户列表' }
    }, {
      path: 'reservation',
      name: 'reservation',
      component: () => import('@/views/account/reservation'),
      meta: { title: '预约列表' }
    }, {
      path: 'recharge',
      name: 'recharge',
      component: () => import('@/views/account/useRecharge'),
      meta: { title: '充值列表' }
    },
    {
      path:'withdrawal',
      name: 'withdrawal',
     component: () => import('@/views/Withdrawal/index.vue'),
     meta: { title: '提现钱包记录' }
    }
  ]
  },
  {
    path: '/wine',
    component: Layout,
    meta: { title: '酒品管理', icon: 'el-icon-goblet-full' },
    children: [{
      path: 'wine',
      name: 'wine',
      props: true,
      component: () => import('@/views/wine/index'),
      meta: { title: '酒品管理' }
    }, {
      path: 'winetype',
      name: 'winetype',
      component: () => import('@/views/wine/winetype'),
      meta: { title: '酒类型管理' }
    },
    {
      path: 'add',
      name: 'add',
      props: true,
      component: () => import('@/views/wine/add'),
      meta: { title: '酒品添加', hidden: true }
    }]
  },

  {
    path: '/active',
    component: Layout,
    meta: { title: '活动管理', icon: 'el-icon-orange' },
    children: [{
      path: 'active',
      name: 'active',
      component: () => import('@/views/active/index'),
      meta: { title: '活动商品' }
    }, {
      path: 'activeadd',
      name: 'activeadd',
      props: true,
      component: () => import('@/views/active/add'),
      meta: { title: '活动酒品添加', hidden: true }
    }, {
      path: 'activedite',
      name: 'activedite',
      props: true,
      component: () => import('@/views/active/update'),
      meta: { title: '活动酒品编辑', hidden: true }
    }, {
      path: 'type',
      name: 'type',
      component: () => import('@/views/active/active'),
      meta: { title: '活动类型管理' }
    },]
  },
  {
    path: '/agent',
    component: Layout,
    meta: { title: '客服管理', icon: 'el-icon-orange' },
    children: [{
      path: 'agent',
      name: 'agent',
      component: () => import('@/views/setting/agent'),
      meta: { title: '客服管理', icon: '' }
    }],
  
  },
  {
    path: '/evaluate',
    component: Layout,
    meta: { title: '评价管理', icon: 'el-icon-orange' },
    children: [{
      path: 'evaluate',
      name: 'evaluate',
      component: () => import('@/views/evaluate/index'),
      meta: { title: '评价管理', icon: '' }
    }],
  
  },
  {
    path: '/logistics',
    component: Layout,
    meta: { title: '物流管理', icon: 'el-icon-orange' },
    children: [{
      path: 'oderlist',
      name: 'oderlist',
      component: () => import('@/views/logOder/index'),
      meta: { title: '物流管理', icon: '' }
    }],
  
  },
  {
    path: '/coupon',
    component: Layout,
    meta: { title: '优惠劵管理', icon: 'el-icon-orange' },
    children: [{
      path: 'coupon',
      name: 'coupon',
      component: () => import('@/views/coupon/index'),
      meta: { title: '优惠劵管理', icon: '' }
    }],
  
  }
  // 404 page must be placed at the end !!!
  // { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
